
/**
 * 
 * @param {Function} fn 这个是回调函数,通过懒加载函数,判定滚动条要到达边界阈值的时候,回调这个函数
 * @param {Number} threshold 滚动条到底部的边界阈值
 */

 function lazyLoad(fn, threshold = 100) {
    let flag = true;
    window.onscroll = function () { 
        let scrollTop = document.documentElement.scrollTop;
        let clientHeight = document.documentElement.clientHeight;
        let scrollHeight = document.documentElement.scrollHeight;
        let scrollBottom = scrollHeight - (scrollTop + clientHeight)
        if (scrollBottom <= threshold) {
            if (flag) {
                flag = false;
                fn()
            }
        } else {
            flag = true;
        }
    }
}
